from django.db import models
from django.contrib.auth.models import AbstractUser


# Create your models here.
class Admin(models.Model):
    """ 管理员表 """
    username = models.CharField(verbose_name="管理员名", max_length=32, unique=True)
    password = models.CharField(verbose_name="密码", max_length=64)
    email = models.EmailField('邮箱', default=None)
    gname = models.CharField(verbose_name="驾校名称", max_length=100)

    class Meta:
        # 选择这个表之后显示的名字
        verbose_name = '管理员'
        verbose_name_plural = '管理员'

    def __str__(self):
        return self.username


class Yonghu(models.Model):
    """ 用户表 """
    username = models.CharField(verbose_name="用户名", max_length=32, unique=True)
    password = models.CharField(verbose_name="密码", max_length=64)
    email = models.EmailField('邮箱', default=None)
    dianhua = models.DecimalField(max_digits=11, decimal_places=0, verbose_name='手机号')
    head = models.ImageField(upload_to='touxiang/', verbose_name='证件照')
    age = models.IntegerField(verbose_name='年龄')
    idnumber = models.DecimalField(max_digits=18, decimal_places=0, verbose_name='身份证号')
    gender_choices = (
        (1, '男'),
        (2, '女')
    )
    gender = models.SmallIntegerField(verbose_name='性别', choices=gender_choices)
    gname = models.CharField(verbose_name="驾校名称", max_length=100, null=True, blank=True)

    class Meta:
        # 选择这个表之后显示的名字
        verbose_name = '用户'
        verbose_name_plural = '用户'

    def __str__(self):
        return self.username

class Category(models.Model):
    """ 类别表 """
    cname = models.CharField(verbose_name="类别名程", max_length=20)

    class Meta:
        # 选择这个表之后显示的名字
        verbose_name = '类别表'
        verbose_name_plural = '类别表'

    def __str__(self):
        return self.cname


class Goods(models.Model):
    """ 驾校表 """
    gname = models.CharField(verbose_name="驾校名称", max_length=100)
    Category = models.ForeignKey(Category, on_delete=models.CASCADE, verbose_name='类别ID')
    sname = models.CharField(verbose_name="考证类别名称", max_length=50)
    colorurl = models.ImageField(upload_to='color/', verbose_name='相关图片地址')
    price = models.DecimalField(max_digits=5, decimal_places=0, verbose_name='价格')

    class Meta:
        # 选择这个表之后显示的名字
        verbose_name = '驾校表'
        verbose_name_plural = '驾校表'

    def __str__(self):
        return self.gname


class Cart(models.Model):
    """ 收藏表 """
    goodsid = models.PositiveBigIntegerField(verbose_name='类型ID')
    gname = models.CharField(verbose_name="类别图", max_length=255)
    Category = models.CharField(verbose_name="套餐类型", max_length=255)
    colorurl = models.CharField(verbose_name="相关照片", max_length=255)
    sname = models.CharField(verbose_name="类别名", max_length=50)
    user = models.ForeignKey(Yonghu, on_delete=models.CASCADE, verbose_name="用户")
    dianhua = models.CharField(verbose_name="手机号", max_length=64, default=None)
    price = models.DecimalField(max_digits=5, decimal_places=0, verbose_name='价格')

    class Meta:
        # 选择这个表之后显示的名字
        verbose_name = '收藏表 '
        verbose_name_plural = '收藏表'

    def __str__(self):
        return self.user.username


class Order(models.Model):
    """报名表"""
    user = models.ForeignKey(Yonghu, on_delete=models.CASCADE, verbose_name="用户")
    dianhua = models.CharField(verbose_name="手机号", max_length=64, default=None)
<<<<<<< HEAD
    order_date = models.DateField(auto_now_add=True, verbose_name='报名时间')
=======
    order_date = models.DateField(auto_now_add=True, verbose_name='报名时间时间')
>>>>>>> f0eb04185cbc15f17a793618efb075babdcd937b
    Category = models.CharField(verbose_name="套餐类型", max_length=255)
    goodsid = models.PositiveBigIntegerField(verbose_name='类型ID')
    sname = models.CharField(verbose_name="类别名", max_length=50)
    gname = models.CharField(verbose_name="类别图", max_length=255)
    colorurl = models.CharField(verbose_name="相关图片", max_length=255)
    price = models.DecimalField(max_digits=5, decimal_places=0, verbose_name='价格')
    status_choices = (
        (1, "报名成功"),
        (2, "报名失败"),
        (3, "待审核"),
    )
    status = models.SmallIntegerField(verbose_name="状态", choices=status_choices, default=3)
<<<<<<< HEAD
    head = models.CharField(verbose_name="证件照", max_length=250)
=======
    head = models.CharField(verbose_name="证件照", max_length=32)
>>>>>>> f0eb04185cbc15f17a793618efb075babdcd937b
    age = models.IntegerField(verbose_name='年龄')
    idnumber = models.DecimalField(max_digits=18, decimal_places=0, verbose_name='身份证号')
    gender_choices = (
        (1, '男'),
        (2, '女')
    )
    gender = models.SmallIntegerField(verbose_name='性别', choices=gender_choices)
<<<<<<< HEAD
    enlist_choices = (
        (1, '正在报名'),
        (2, '取消报名')
    )
    enlist = models.SmallIntegerField(verbose_name='报名状态', choices=enlist_choices)
=======
>>>>>>> f0eb04185cbc15f17a793618efb075babdcd937b

    class Meta:
        # 选择这个表之后显示的名字
        verbose_name = '报名表'
        verbose_name_plural = '报名表'

    def __str__(self):
        return self.gname
